package com.letchat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.letchat.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where username = #{username} and password = #{password}")
    User getUserByUsernameAndPassword(User user);

    @Select("select id,name, img_code from user where id = #{userId}")
    User getIdAndNameAndImgById(Integer userId);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into user(username,password,name,email) values(#{username},#{password},#{username},#{email})")
    void save(User u);
}
